home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / ftn / malloc.z / malloc
Encoding:
Text File  |  1998-10-30  |  4.1 KB  |  133 lines

  1.  
  2.  
  3.  
  4. MMMMAAAALLLLLLLLOOOOCCCC((((3333FFFF))))                                                          MMMMAAAALLLLLLLLOOOOCCCC((((3333FFFF))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      malloc, free - main memory allocator
  10.  
  11. FFFFOOOORRRRTTTTRRRRAAAANNNN SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      ppppooooiiiinnnntttteeeerrrr ((((iiiippppttttrrrr,,,, aaaarrrrrrrr))))
  13.      ddddiiiimmmmeeeennnnssssiiiioooonnnn aaaarrrrrrrr((((1111))))
  14.      iiiinnnntttteeeeggggeeeerrrr nnnnbbbbyyyytttteeeessss
  15.  
  16.      iiiippppttttrrrr ==== mmmmaaaalllllllloooocccc((((nnnnbbbbyyyytttteeeessss))))
  17.  
  18.      ccccaaaallllllll ffffrrrreeeeeeee((((iiiippppttttrrrr))))
  19.  
  20. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  21.      _m_a_l_l_o_c and _f_r_e_e provide a simple general-purpose memory allocation
  22.      package.  _m_a_l_l_o_c returns a pointer to a block of at least _n_b_y_t_e_s bytes
  23.      suitably aligned for any use.
  24.  
  25.      _a_r_r can be an array of any type.  After the call to _m_a_l_l_o_c the array _a_r_r
  26.      can be used as if it has been declared as an array with _n_b_y_t_e_s in length.
  27.      All references to this array will be deferenced using the value assigned
  28.      to _i_p_t_r in the _m_a_l_l_o_c call to refer to the space allocated by _m_a_l_l_o_c.
  29.  
  30.      The argument to _f_r_e_e is a pointer to a block previously allocated by
  31.      _m_a_l_l_o_c; after _f_r_e_e is performed this space is made available for further
  32.      allocation, but its contents are left undisturbed.
  33.  
  34.      Undefined results will occur if the space assigned by _m_a_l_l_o_c is overrun
  35.      or if some random number is handed to _f_r_e_e.
  36.  
  37.      _m_a_l_l_o_c allocates the first big enough contiguous reach of free space
  38.      found in a circular search from the last block allocated or freed,
  39.      coalescing adjacent free blocks as it searches.  It calls _s_b_r_k [see
  40.      _b_r_k(2)] to get more memory from the system when there is no suitable
  41.      space already free.
  42.  
  43. DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS
  44.      _m_a_l_l_o_c, returns a NULL pointer if there is no available memory or if the
  45.      arena has been detectably corrupted by storing outside the bounds of a
  46.      block.  When this happens the block pointed to by _i_p_t_r may be destroyed.
  47.  
  48. NNNNOOOOTTTTEEEESSSS
  49.      Search time increases when many objects have been allocated; that is, if
  50.      a program allocates but never frees, then each successive allocation
  51.      takes longer.
  52.  
  53.      Note that the system may be configured with virtual swap space.  This
  54.      allows processes to allocate more virtual memory than is actually
  55.      available, allowing the use of sparse addressing, successful forks and
  56.      subsequent execs by programs larger than 1/2 the available virtual
  57.      memory, and so forth.  Thus programs using malloc may get a successful
  58.      return, but later be sent the SIGKILL signal if virtual memory was
  59.      overcommitted, and processes attempt to actually use all of the
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. MMMMAAAALLLLLLLLOOOOCCCC((((3333FFFF))))                                                          MMMMAAAALLLLLLLLOOOOCCCC((((3333FFFF))))
  71.  
  72.  
  73.  
  74.      overcommitted memory.  If the system has no virtual swap space
  75.      configured, then processes are limited to using no more virtual memory
  76.      than the sum of physical memory and swap space.  See the section on
  77.      "Logical Swap Space" in the swap(1M) man page for more information.
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.